<template>
	<view>
		
		
		
	<view style="font-size: 26upx;color: #a0a0a0;margin-top: 10upx;"
	 v-for="(item, index) in message" :index="index" :key="index"  >
		<view style="text-align: center;margin: 10upx 0;">
			{{item.addtime}}
		</view>
		<view style="border-radius: 10upx;padding: 20upx 40upx;background-color: #e5f2f2;margin: 10upx 20upx;">
			<view v-if="item.uid==0">[{{item.name}}]<text style="padding-left: 5upx;">{{item.content}}</text> </view>
			
			<view v-else>[{{item.nickName}}]<text style="padding-left: 5upx;">{{item.content}}</text></view>
			
			<view v-if="item.uid!=0">联系方式：{{item.phone||'暂无'}}</view>
			
		</view>
	</view>
	
	<uni-load-more :status="status" :content-text="contentText" />
	
	
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		data() {
			return {
				//系统消息列表
				message:[],
				page:1,
				newData:[],
				uid:uni.getStorageSync('userInfo').uid,
			}
		},
		onLoad() {
			uni.startPullDownRefresh();
		},
		onReachBottom : function(){
		            this.status = 'more';
		            this.loadMoreFunc();
		},
		onPullDownRefresh() {
		        //监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
		        //console.log('refresh');
				
				
				this.loadData('first');
		        setTimeout(function () {
		            uni.stopPullDownRefresh();  //停止下拉刷新动画
		        }, 1000);
		},
		methods: {
			loadMoreFunc(){
				console.log("更多加载");
				
				
				this.loadData('more');
				
				
			},
			loadData(status){
				
				if(status=='first'){
					
					this.page=1;
					this.message=[];
				}
				const sendData = {
					"page":this.page,
					"uid":this.uid
					
				};
					uni.request({
						url: this.userApi+'/message', //仅为示例，并非真实接口地址。
						data: sendData,
						dataType: 'json',
						method: 'get',
						header: {
							'content-type': 'application/json' // 微信默认就是
						},
						success: res => {
							if (res.statusCode !== 404) {
								//console.log(res.data );
								this.page+=1;
								
								this.message.push(...res.data);
								
							} else {
								this.status='noMore'
								console.log("数据没有");
							}
						}
					});
				
			}
		}
	}
</script>

<style>

</style>
